Skip to main content

Last Update: 2025/3/26

SenseFlow Workflow API

The SenseFlow Workflow API allows you to execute and manage workflows. This is suitable for translation, article writing, summarization AI, and other non-session based applications.

Endpoints

Execute Workflow

POST https://platform.llmprovider.ai/v1/agent/workflows/run

Execute a workflow. Cannot be executed without a published workflow.

Request Headers

HeaderValue
AuthorizationBearer YOUR_API_KEY
Content-Typeapplication/json

Request Body

ParameterTypeRequiredDescription
modelstringYesagent name
inputsobjectYesKey-value pairs of variables defined in the App
response_modestringYesstreaming (recommended) or blocking
userstringYesUnique identifier for the end user
filesarrayNoArray of file objects for multimodal inputs
Files Object Structure
FieldTypeDescription
typestringFile type (document, image, audio, video, custom)
transfer_methodstringremote_url or local_file
urlstringFile URL (when transfer_method is remote_url)
upload_file_idstringFile ID (when transfer_method is local_file)
Example
{
"inputs": {},
"response_mode": "streaming",
"user": "abc-123"
}

Response

The response varies based on the response_mode:

  • For blocking mode: Returns a WorkflowResponse object
  • For streaming mode: Returns a stream of ChunkWorkflowResponse objects
WorkflowResponse Structure
FieldTypeDescription
workflow_run_idstringUnique ID of workflow execution
task_idstringTask ID for request tracking
dataobjectExecution result details
Data Object Structure
FieldTypeDescription
idstringID of workflow execution
workflow_idstringID of related workflow
statusstringStatus: running/succeeded/failed/stopped
outputsobjectContent of output
errorstringOptional reason of error
elapsed_timefloatTotal seconds used
total_tokensintegerTokens used
total_stepsintegerTotal steps executed
created_attimestampStart time
finished_attimestampEnd time

Streaming Response Events

Each streaming chunk starts with data: and chunks are separated by \n\n. Different event types include:

Event TypeDescriptionFields
workflow_startedWorkflow starts executiontask_id, workflow_run_id, data(id, workflow_id, sequence_number, created_at)
node_startedNode execution startedtask_id, workflow_run_id, data(id, node_id, node_type, title, index, predecessor_node_id, inputs, created_at)
node_finishedNode execution endedtask_id, workflow_run_id, data(id, node_id, node_type, title, index, predecessor_node_id, inputs, process_data, outputs, status, error, elapsed_time, execution_metadata, created_at)
workflow_finishedworkflow execution endedtask_id, workflow_run_id, event, data(id, workflow_id, status, outputs, error, elapsed_time, total_tokens, total_steps, created_at, finished_at)
errorStream error eventtask_id, message_id, status, code, message
pingKeep-alive ping (every 10s)-
Example Responses

For blocking mode:

{
"workflow_run_id": "djflajgkldjgd",
"task_id": "9da23599-e713-473b-982c-4328d4f5c78a",
"data": {
"id": "fdlsjfjejkghjda",
"workflow_id": "fldjaslkfjlsda",
"status": "succeeded",
"outputs": {
"text": "Nice to meet you."
},
"error": null,
"elapsed_time": 0.875,
"total_tokens": 3562,
"total_steps": 8,
"created_at": 1705407629,
"finished_at": 1727807631
}
}

For streaming mode:

  data: {"event": "workflow_started", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "workflow_id": "dfjasklfjdslag", "sequence_number": 1, "created_at": 1679586595}}
data: {"event": "node_started", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "node_id": "dfjasklfjdslag", "node_type": "start", "title": "Start", "index": 0, "predecessor_node_id": "fdljewklfklgejlglsd", "inputs": {}, "created_at": 1679586595}}
data: {"event": "node_finished", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "node_id": "dfjasklfjdslag", "node_type": "start", "title": "Start", "index": 0, "predecessor_node_id": "fdljewklfklgejlglsd", "inputs": {}, "outputs": {}, "status": "succeeded", "elapsed_time": 0.324, "execution_metadata": {"total_tokens": 63127864, "total_price": 2.378, "currency": "USD"}, "created_at": 1679586595}}
data: {"event": "workflow_finished", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "workflow_id": "dfjasklfjdslag", "outputs": {}, "status": "succeeded", "elapsed_time": 0.324, "total_tokens": 63127864, "total_steps": "1", "created_at": 1679586595, "finished_at": 1679976595}}
data: {"event": "tts_message", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"}
data: {"event": "tts_message_end", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": ""}

Example Request

curl -X POST 'https://platform.llmprovider.ai/v1/agent/workflows/run' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "",
"inputs": {},
"response_mode": "streaming",
"user": "abc-123"
}'

Get Workflow Run Detail

GET https://platform.llmprovider.ai/v1/agent/workflows/run/:workflow_id

Retrieve the execution results of a workflow task based on the workflow execution ID.

Request Headers

HeaderValue
AuthorizationBearer YOUR_API_KEY

Path Parameters

ParameterTypeDescription
workflow_idstringWorkflow execution ID

Query Parameters

ParameterTypeDescription
modelstringagent name

Response

FieldTypeDescription
idstringID of workflow execution
workflow_idstringID of related workflow
statusstringStatus: running/succeeded/failed/stopped
inputsobjectContent of input
outputsobjectContent of output
errorstringReason of error
total_stepsintegerTotal steps of task
total_tokensintegerTotal tokens used
created_attimestampStart time
finished_attimestampEnd time
elapsed_timefloatTotal seconds used
Example Response
{
"id": "b1ad3277-089e-42c6-9dff-6820d94fbc76",
"workflow_id": "19eff89f-ec03-4f75-b0fc-897e7effea02",
"status": "succeeded",
"inputs": "{\"sys.files\": [], \"sys.user_id\": \"abc-123\"}",
"outputs": null,
"error": null,
"total_steps": 3,
"total_tokens": 0,
"created_at": "Thu, 18 Jul 2024 03:17:40 -0000",
"finished_at": "Thu, 18 Jul 2024 03:18:10 -0000",
"elapsed_time": 30.098514399956912
}

Example Request

curl -X GET 'https://platform.llmprovider.ai/v1/agent/workflows/run/workflow_123?model=' \
--header 'Authorization: Bearer YOUR_API_KEY'

Stop Workflow

POST https://platform.llmprovider.ai/v1/agent/workflows/tasks/:task_id/stop

Stop a running workflow. Only available for streaming mode.

Request Headers

HeaderValue
AuthorizationBearer YOUR_API_KEY
Content-Typeapplication/json

Path Parameters

ParameterTypeDescription
task_idstringTask ID obtained from the streaming response

Request Body Parameters

ParameterTypeRequiredDescription
modelstringYesAgent name
userstringYesUser identifier (must match the workflow API user ID)

Response

FieldTypeDescription
resultstringAlways "success"
Example Response
{
"result": "success"
}

Example Request

curl -X POST 'https://platform.llmprovider.ai/v1/agent/workflows/tasks/task_123/stop' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "",
"user": "abc-123"
}'

Get Workflow Logs

GET https://platform.llmprovider.ai/v1/agent/workflows/logs

Returns workflow execution logs, with pagination support.

Request Headers

HeaderValue
AuthorizationBearer YOUR_API_KEY

Query Parameters

ParameterTypeDescription
modelstringAgent name
keywordstringKeyword to search
statusstringFilter by status (succeeded/failed/stopped)
pageintegerCurrent page (default: 1)
limitintegerItems per page (default: 20)

Response

FieldTypeDescription
pageintegerCurrent page
limitintegerItems per page
totalintegerTotal number of items
has_morebooleanWhether there are more pages
dataarrayArray of workflow log objects

Example Request

curl -X GET 'https://platform.llmprovider.ai/v1/agent/workflows/logs?model=&page=1&limit=20' \
--header 'Authorization: Bearer YOUR_API_KEY'